const { Sequelize } = require("sequelize");
const isWin = process.platform === "win32";
const options = {
  host: "localhost",
  dialect: "mysql",
  timezone: "+8:00",
  dialectOptions: { useUTC: false },
  pool: { max: 20, min: 5 },
  logging: false,
  ...(isWin ? {} : { port: 6036 }),
};
const config = {
  database: "chinesemedicine",
  username: process.env.DB_USER,
  password: isWin
    ? process.env.DB_WIN_PASSWORD
    : process.env.DB_UBUNTU_PASSWORD,
  options,
};
module.exports = new Sequelize(
  config.database,
  config.username,
  config.password,
  config.options
);
